package com.akaovi.exp;

import java.io.*;
import java.nio.charset.StandardCharsets;

/**
 * @author akaovi
 * @version 1.0
 * @description
 * @date 2022/11/14 15:13
 * @since 2022/11/14 15:13
 */
public class Three {

    public static void main(String[] args) {
        FileOutputStream fos = null;
        FileInputStream fis = null;

        File file1 = new File("D:\\javaProject\\javaExp\\exp8\\src\\main\\java\\com\\akaovi\\exp\\Two.java");
        File file2 = new File("D:\\javaProject\\javaExp\\exp8\\src\\main\\resources\\java.txt");

        try {
            fis = new FileInputStream(file1);
            byte[] bytes = fis.readAllBytes();
            System.out.println(new String(bytes, StandardCharsets.UTF_8));
            fos = new FileOutputStream(file2);
            fos.write(bytes);
            fos.flush();
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            if (fis != null) {
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            if (fos != null) {
                try {
                    fos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    }

}
